﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;

namespace Sio.Mdm.Utils.Collections
{
    /// <summary>
    /// Event argument for item actions in collections
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class ItemEventArgs<T> : EventArgs
    {
        /// <summary>
        /// Construct arguments with specified value and index
        /// </summary>
        /// <param name="value"></param>
        /// <param name="index"></param>
        public ItemEventArgs(T value, int index)
        {
            _value = value;
            _index = index;
        }

        private T _value;
        /// <summary>
        /// Get value of item
        /// </summary>
        public T Value
        {
            get
            {
                return _value;
            }
        }
        private int _index;
        /// <summary>
        /// Get index of item
        /// </summary>
        public int Index
        {
            get
            {
                return _index;
            }
        }
    }

    /// <summary>
    /// Event arguments for operations that can be canceled
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class ItemCancelEventArgs<T> : ItemEventArgs<T>
    {
        /// <summary>
        /// Construct event arguments
        /// </summary>
        /// <param name="value"></param>
        /// <param name="index"></param>
        public ItemCancelEventArgs(T value, int index)
            : base(value, index)
        {
        }

        private bool _cancel;
        /// <summary>
        /// Gets or sets wheater operations should be canceled
        /// </summary>
        public bool Cancel
        {
            get
            {
                return _cancel;
            }
            set
            {
                _cancel = value;
            }
        }
    }
}
